//
//  TableHeadTitleView.m
//  HZAPP
//
//  Created by huazi on 15/10/11.
//  Copyright (c) 2015年 huazi. All rights reserved.
//

#import "TableHeadTitleView.h"
#define kTableHeadTitleViewHeight  30.0f
@interface TableHeadTitleView()
@property (strong, nonatomic)NSString *title;
@end
@implementation TableHeadTitleView
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(id)initWithTitle:(NSString *)title {
    self =[self initWithTitle:title AndFrame:CGRectMake(0, 0, DeviceWidth, kTableHeadTitleViewHeight)];
    return self;
}
-(id)initWithTitle:(NSString *)title AndFrame:(CGRect)frame {
    self =[super initWithFrame:frame];
    if (self) {
        self.title =title;
        [self setSubviews];
    }
    return self;
}
- (void)setSubviews {
    float widthTitle =[NSString calculateTextWidth:100 Content:self.title font:themeFont15];
    UILabel *labelTitle =[[UILabel alloc] initWithFrame:CGRectMake(10, 0, widthTitle+10, kTableHeadTitleViewHeight)];
    labelTitle.text =self.title;
    labelTitle.textColor =[UIColor whiteColor];
    labelTitle.font =themeFont13;
    labelTitle.backgroundColor =kcolorThemeNav;
    labelTitle.textAlignment =NSTextAlignmentCenter;
    [self addSubview:labelTitle];
    
    UIView *lineView =[[UIView alloc] initWithFrame:CGRectMake(10, 29.7, DeviceWidth-20, 0.3)];
    lineView.backgroundColor =kcolorThemeNav;
    [self addSubview:lineView];
}
@end
